/**
 * 涉密数据,只能修改，不能查看
 */
Rsd.define('Rsd.form.Secret', {
    extend: 'Rsd.form.Label',
    xtype: 'secret',
    margin:'2 0 2 0',
//    height: 25,
//    width: 80,
    inputType: 'text',
    //ctrlCls: 'x-control-privacy',
    handler: null,
    /**
     * @description 数据查看器配置
     * {
        style:null,
        text:'[查 看]',
        handler:''
       }
     */
     //viewor:null,
     /**
      * 代替显示的文字内容
      */
     value:'涉密数据已隐藏显示',
     /**
      * 
      * @param {*} config 
      */
    constructor: function constructor(config) {
        config = config || {};
        this.apply(config);
        this.readonly = true;
        this.viewor = this.viewor||{};
    },
    /**
     * 初始化 仅创建对象，并未渲染dom结构
     */
     initComponentEx: function initComponentEx() 
     {
         this.callParent();

         var me = this;
         var viewor = me.viewor;
         if (me.readable) {
             var btn = document.createElement('a');
             viewor.element = btn;

             btn.id = this.id + '__viewer';
             btn.innerHTML = viewor.text || "[查看]";
             btn.title = viewor.tip || viewor.title || '查看数据';
             btn.style.marginRight = "8px";
             btn.style.marginLeft = "10px";
             btn.style.float = "right";
             btn.style.position = "relative";
             btn.style.zIndex = 9999;
             btn.style.lineHeight = me.height + 'px';
             btn.href = "javascript:void(0);"

             me.ctrl.element.ondblclick = btn.onclick = function (event) {
                 if (viewor.handler || viewor.fn) {
                     me.funApplyByIOC(viewor.handler || viewor.fn, [me, event]);
                     return;
                 }
                Rsd.showHtml("show data viewer");
             }
             me.setElStyle(btn, viewor.style || {});
         }

         if (me.editable) {
             var btnUpdate = document.createElement('a');
             viewor.updateElement = btnUpdate;

             btnUpdate.id = this.id + '__update';
             btnUpdate.innerHTML = viewor.updateText || "[修改]";
             btnUpdate.title = viewor.updateTip || viewor.updateTitle || '修改数据';
             btnUpdate.style.marginRight = "8px";
             btnUpdate.style.marginLeft = "0px";
             btnUpdate.style.float = "right";
             btnUpdate.style.position = "relative";
             btnUpdate.style.zIndex = 9999;
             btnUpdate.style.lineHeight = me.height + 'px';
             btnUpdate.href = "javascript:void(0);"
             btnUpdate.onclick = function ( event) {
                 if (viewor.updateHandler || viewor.updateFn) {
                     me.funApplyByIOC(viewor.updateHandler || viewor.updateFn, [me, event]);
                 }
                 //show editor view
                 Rsd.showHtml(" show data editor");
                 //me.setValue("");
             }
         }
                
     },
     /**
      * 
      */
     onAfterRender:function onAfterRender()
     {
        this.callParent();

        if(this.viewor && this.viewor.element)
        { 
            this.dom.appendChild(this.viewor.element);
        }

        if(this.viewor && this.viewor.updateElement)
        { 
            this.dom.appendChild(this.viewor.updateElement);
        }
     }

},function(type){

    var _vieworGetter = function () {
        return this.___viewor;
    };

    var _vieworSetter = function (value) {
         
        this.___viewor = Rsd.apply({style:null, text:'[查看]', handler:''},value||{}); 
    }

    this.defineProperty(type,"viewor", _vieworGetter, _vieworSetter,false);
});

